<template>
  <my-simple-page
    :tableTitle="tableTitle"
    :search-fields="searchFields"
    :columns="columns"
    :edit-fields="editFields"
    :search-url="searchUrl"
    :save-url="saveUrl"
    :delete-url="deleteUrl">
  </my-simple-page>
</template>

<script>
  export default {
    name: "dict-index",
    data(){
      return{
        searchFields: [
          {
            type: 'input',
            label: '字典名称',
            prop: 'name'
          }
        ],
        tableTitle: '字典列表',
        columns: [
          {label:'字典名称',prop: 'name'},
          {label:'字典值',prop: 'dictValue'},
          {label:'描述',prop: 'dictDesc'}
          ],
        editFields: [
          {
            type: 'input',
            label: '字典名称',
            prop: 'name',
            rules:{ required: true, message: '字典名称不能为空', trigger: 'blur' }
          },
          {
            type: 'number',
            label: '字典值',
            prop: 'dictValue',
            rules:{ required: true, message: '字典值不能为空', trigger: 'blur' }
          },
          {
            type: 'select',
            label: '父级字典',
            prop: 'parent',
            url: '/api/sys-config/dict/getDictOption'
          },
          {
            type: 'textarea',
            label: '描述',
            prop: 'dictDesc'
          }
        ],
        searchUrl: '/api/sys-config/dict/getDictList',
        saveUrl: '/api/sys-config/dict/saveDict',
        deleteUrl: '/api/sys-config/dict/deleteDict',
      }
    },
    methods:{
      renderStatus(val){
        switch (val) {
          case 1:
            return "启用";
          case 0:
            return "禁用";
          default:
            return "无"
        }
      }
    }
  }
</script>

<style scoped>

</style>
